#include "bulletBall.h"

#include "stdio.h"
#include "MapSlot.h"

BulletBall* BulletBall::create(CCPoint startPoint,CCPoint endPoint)
{
	char* imgUri = "images\\Plants\\bulletBall.png";
	BulletBall* pbulletBall = new BulletBall(startPoint,endPoint);
	pbulletBall->initWithSpriteFrame(CCSpriteFrame::create(imgUri,CCRect::CCRect(0,0,32,32)));
	pbulletBall->autorelease();
	pbulletBall->StartMove();
	return pbulletBall;
}

void BulletBall::StartMove()
{
	this->setAnchorPoint(RectLayout::Left());
	this->setVisible(true);
	this->setPosition(m_startPoint);
	CCActionInterval* actionTo = CCMoveBy::create(1, ccp(MapSlot::WIDTH*2,0));
	this->runAction( CCRepeatForever::create(actionTo) );
}

void BulletBall::ReStartMove()
{
	this->stopAllActions();
	this->StartMove();
}

cocos2d::CCPoint BulletBall::GetLocation()
{
	//return this->convertToWorldSpaceAR(this->getPosition());
	return this->getPosition();
}

cocos2d::CCRect BulletBall::Rect()
{
	return CCRectMake(this->GetLocation().x, this->GetLocation().y, (this->getTextureRect().size.width)/2, (this->getTextureRect().size.height)/2);
}
